from app.database.connections import db
import MySQLdb


class Memory(db.Model):
    id = db.Column(db.BigInteger, primary_key=True)
    mac_code = db.Column(db.String)
    total_memory_size = db.Column(db.Numeric)
    available_size = db.Column(db.Numeric)
    used_percent = db.Column(db.Numeric)
    used_size = db.Column(db.Numeric)
    memory_usage = db.Column(db.Numeric)
    spare_size = db.Column(db.Numeric)
    # -----------------------------
    swap_memory_total = db.Column(db.Numeric)
    swap_used_percent = db.Column(db.Numeric)
    swap_used_size = db.Column(db.Numeric)
    swap_memory_usage = db.Column(db.Numeric)
    swap_spare_size = db.Column(db.Numeric)
    swap_sin = db.Column(db.Numeric)
    swap_sout = db.Column(db.Numeric)

    # create_user_id = db.Column(db.String)
    # create_time = db.Column(db.String)
    # update_user_id = db.Column(db.String)
    # update_time = db.Column(db.String)
    # yn = db.Column(db.String)

    def __init__(self,mac_code,total_memory_size,available_size,used_percent,used_size,memory_usage,spare_size,swap_memory_total,swap_used_percent,swap_used_size,swap_memory_usage,swap_spare_size,swap_sin,swap_sout):
        self.mac_code = mac_code
        self.total_memory_size = total_memory_size
        self.available_size = available_size
        self.used_percent = used_percent
        self.used_size = used_size
        self.memory_usage = memory_usage
        self.spare_size = spare_size
        self.swap_memory_total = swap_memory_total
        self.swap_used_percent = swap_used_percent
        self.swap_used_size = swap_used_size
        self.swap_memory_usage = swap_memory_usage
        self.swap_spare_size = swap_spare_size
        self.swap_sin = swap_sin
        self.swap_sout = swap_sout

    def __repr__(self):
        return '<memory: %r,%r,%r,%r >' % (self.id , self.mac_code , self.total_memory_size,self.available_size)